﻿using Identity_JWT_WebAPI.Dao;
using Microsoft.EntityFrameworkCore;

namespace Identity_JWT_WebAPI
{
    public static class RegisterMySQL
    {
        public static WebApplicationBuilder AddMySQL(this WebApplicationBuilder builder)
        {
            var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
            builder.Services.AddDbContext<MyDbContext>(options =>
                options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)).EnableDetailedErrors().EnableSensitiveDataLogging());
            return builder;
        }
    }
}
